﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

/// <summary>
///EnumFormField 的摘要说明
/// </summary>
public class EnumFormField:BaseFormShow
{
	public EnumFormField()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    public override IEnumerable<System.Web.UI.Control> GetFieldContrls(System.Reflection.PropertyInfo propertyInfo,object value)
    {
        DropDownList field = new DropDownList();
        field.ID = propertyInfo.Name;

        field.DataSource = Enum.GetValues(propertyInfo.PropertyType);
        field.DataBind();

        field.SelectedValue = value.ToString();

        yield return field;
    }

    public override object GetValue(System.Reflection.PropertyInfo propertyInfo, string value)
    {
        return Enum.Parse(propertyInfo.PropertyType, value);
    }
}
